package com.fang.api_encryption.controller;

import com.fang.api_encryption.common.ResponseEntity;
import com.fang.api_encryption.entrty.User;
import com.fang.api_encryption.entrty.UserType;

import com.fang.api_encryption.entrty.dto.Login;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author Bernie_fang
 * @Date 2023/10/15 22:20
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/list")
    public ResponseEntity listUser() {
        List<User> users = new ArrayList<>();
        User u = new User();
        u.setId(1);
        u.setName("boyka");
        u.setRegisterTime(LocalDateTime.now());
        u.setUserType(UserType.COMMON);
        users.add(u);
        ResponseEntity response = new ResponseEntity();
        response.setCode(200);
        response.setData(users);
        response.setMsg("用户列表查询成功");
        return response;
    }

    @PostMapping("/login")
    public ResponseEntity testPost(@RequestBody Login login){
        login.setUsername(login.getUsername() + "-success");
        login.setPassword(login.getPassword() + "-success");
        ResponseEntity response = new ResponseEntity();
        response.setCode(200);
        response.setData(login);
        response.setMsg("用户列表查询成功");
        return response;
    }

}

